import { _decorator, Component, Node,Vec3} from "cc";
import { Notifications } from "../easyFramework/notifications";
import { LocalCache } from "../utils/LocalCache";

const { ccclass, property } = _decorator;

//子弹结构
export interface Bullet {
    type: number,//猎人类型humanType
    pos: Vec3,//位置
    targetPos: Vec3,
    scale: Vec3,//缩放
    jsonArm: Object,
    jsonArmType: Object,
    enemyId: number,
}

//基础数据结构
class BaseData {
    protected dictCache
    protected cacheName
    constructor(cacheName) {
        this.cacheName = cacheName;
    }
    //重新开始
    resetCache (){
 
    }
    //复活
    reAlive (){
        
    }
    protected emit(eventName, data?) {
        Notifications.emit(eventName, data);
    }
    protected on(eventName, func, target) {
        Notifications.on(eventName, func, target);
    }
    protected getCache() {
        return LocalCache.getItem(this.cacheName);
    }
    protected updateCache() {
        LocalCache.setItem(this.cacheName, this.dictCache);
    }
    //根据id从数组中获取需要的配置
    protected getListCfgById(cfg, id) {
        for(let i = 0; i < cfg.length; i ++){
            if(cfg[i].ID == id) return cfg[i];
        }
        return null;
    }
}
 
export default BaseData;